package com.itheima.health.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.health.mapper.WxPayMapper;
import com.itheima.health.pojo.Order;
import com.itheima.health.service.WxPayService;
import com.itheima.health.utils.PayUtils;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.transaction.annotation.Transactional;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

@Service
@Transactional
public class WxPayServiceImpl extends ServiceImpl<WxPayMapper, Order> implements WxPayService,Serializable{




    @Override
    public Map createOrder(Integer oId) {
        String uuid = UUID.randomUUID().toString();
        uuid = uuid.substring(uuid.length() - 33, uuid.length() - 8);
        String orderId = uuid + oId;
        Integer totalPay = 1;
        String payUrl = PayUtils.createOrder(orderId, totalPay);
        Map map= new HashMap();
        map.put("url",payUrl);
        map.put("oId",orderId);
        return map;
    }

}
